import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [{
        path: '/login',
        name: 'login',
        component: () =>
            import ('../views/login/index.vue')
    },
    {
        path: '/',
        // name: 'layout',
        component: () =>
            import ('@/views/layout'),
        children: [{
                path: '/home',
                name: 'home',
                component: () =>
                    import ('@/views/home')
            },
            {
                path: '/qa',
                name: 'qa',
                component: () =>
                    import ('@/views/qa')
            },
            {
                path: '/word',
                name: 'word',
                component: () =>
                    import ('@/views/word')
            },
            {
                path: '/video',
                name: 'video',
                component: () =>
                    import ('@/views/video')
            },
            {
                path: '/my',
                name: 'my',
                component: () =>
                    import ('@/views/my')
            }
        ]
    },
    {
        path: '/search',
        name: 'search',
        component: () =>
            import ('@/views/search')
    },
    {
        path: '/article/:articleId',
        name: 'articel',
        component: () =>
            import ('@/views/article'),
        props: true //把路由收到的所有params参数通过props传递给子组件
    },
    {
        path: '/user/profile',
        name: 'user-profile',
        component: () =>
            import ('@/views/user-profile')
    }
]

const router = createRouter({
    history: createWebHashHistory(),
    routes
})

export default router